package com.wmx.hb.UEditor;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.net.URL;
import java.util.Map;

/**
 * UEditor 富文本编辑器快速使用入门
 *
 * @author wangMaoXiong
 * @version 1.0
 * @date 2022/12/11 17:13
 */
@RestController
public class UEditorController {

    @GetMapping("ueditor/controller")
    public Map<String, Object> getController(@RequestParam String action) {
        URL url = UEditorController.class.getClassLoader().getResource("UEditor-config.json");
        String config = FileUtil.readString(url, "UTF-8");
        Map<String, Object> map = JSONUtil.toBean(config, Map.class);
        return map;
    }

    @PostMapping("ueditor/controller")
    public Map<String, Object> postController(@RequestParam String action) {
        if (StrUtil.equals(action, "uploadimage")) {

        }
        return null;
    }

}
